<template>
  <!-- 项目实施 - 9问题管理 - tab2完结项目 -->
  <div class="problem-management-end">
    <el-row :gutter="20">
      <el-col :span="24">
        <el-form class="search" :inline="true" :model="formData" label-position="right" label-width="90px">
          <el-row :gutter="12">
            <el-col :span="16" v-if="showSearch == false">
              <advancedFilter></advancedFilter>
            </el-col>
            <el-col :span="6" v-if="showSearch">
              <el-form-item label="项目名称">
                <el-input v-model="formData.ipt1" clearable placeholder="搜索关键字" style="width: 100%;"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6" v-if="showSearch">
              <el-form-item label="费用类型">
                <el-input v-model="formData.ipt2" clearable placeholder="搜索关键字" style="width: 100%;"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="showSearch ? 12 : 8" style="text-align: right;">
              <el-button type="primary">筛选</el-button>
              <el-button @click="resetForm">重置</el-button>
              <el-button type="text" @click="changeSearch"> {{showSearch===true ? '高级筛选' : '普通筛选'}} </el-button>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="24">
        <el-row :gutter="12" style="display: inline-flex;width: 100%;">
          <el-col :span="4" :md="5" :sm="6" class="border-r">
            <el-input v-model="treeSearch" class="tree-search" placeholder="搜索关键字" suffix-icon="el-icon-search"></el-input>
            <el-tree class="cust-tree" node-key="id" :data="treeData" ref="tree" :props="defaultProps" @node-click="handleNodeClick" default-expand-all></el-tree>
          </el-col>
          <el-col :span="20" :md="19" :sm="18">
            <cust-act-table
              ref="custActTable"
              tableType=""
              :list="tableData"
              :colConfigs="customColumns"
              @changePage="changePage"
              @getSelectedRow="showModal"
              :pageNum="page.pageNum"
              :pageSize="page.pageSize"
              :total="page.total"
              :showIdx="false"
              :showAct="false"
              rKey="index"
            ></cust-act-table>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-dialog title="查看" class="btn-modal" :visible.sync="modalState" @close="closeModal" width="800px" :close-on-click-modal="false">
      <modalBtns modalType="table" @close="closeModal('table')"></modalBtns>
      <formName text="问题列表"></formName>
      <div class="form-content">
        <formPart listTitle="基本信息" ref="info1" modalTitle="查看" :formList="formInfo.info1"></formPart>
        <formPart listTitle="处理信息"  ref="info2" modalTitle="查看" :formList="formInfo.info2"></formPart>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { tableData92, customColumns92 } from '../../js/staticData';
import advancedFilter from '../../components/advancedFilter';
import custActTable from "../../components/custActTable.vue";
import modalBtns from '../../components/modalBtns';
import formName from '../../components/formName';
import formPart from '../../components/formPart';
export default {
  name: "problemManagementEnd",
  components: {custActTable, advancedFilter, modalBtns, formName, formPart},
  data() {
    return {
      formData: {
        ipt1: '',
        ipt2: ''
      },
      treeSearch: '',
      treeData: [
        {
          label: '问题状态',
          children: [
            { label: '结果问题', id: 0},
            { label: '过程问题', id: 1},
            { label: '人员问题', id: 2},
            { label: '质量问题', id: 3},
            { label: '设备问题', id: 4}
          ]
        }
      ],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      showSearch: true,
      tableData: tableData92[0],
      customColumns: customColumns92,
      page: {
        pageNum: 1, // 当前页
        pageSize: 10, // 每页条数
        total: 0, // 总条数
      },
      modalState: false,
      formInfo: {
        info1: [
          { l: '问题名称', v: '升级后BUG多影响正常业务开展', type: 'input', span: 12 },
          { l: '项目名称', v: '蓝旗机器人系统升级', type: 'inputIconR', icon: { path:require('../../images/modal-icon1.png'), width: '14px', height: '16px'}, span: 12 },
          { l: '问题类型', v: '过程问题', type: 'select', option: [{l:'结果问题', v: '0'},{l:'过程问题', v: '1'},{l:'人员问题', v: '2'}, {l:'质量问题', v: '3'}, {l:'设备问题', v: '4'}], span: 6 },
          { l: '负责人', v: '苑珙', type: 'inputIconR', icon: { path:require('../../images/modal-icon4.png'), width: '14px', height: '16px'}, span: 6 },
          { l: '新增日期', v: '2024-06-31', type: 'datePicker', span: 6 },
          { l: '问题状态', v: '处理中', type: 'select', option: [{l:'未处理', v: '0'},{l:'处理中', v: '1'},{l:'已解决', v: '2'}], span: 6 },
          { l: '问题说明', v: '系统升级完成后，发现20个BUG待处理。', type: 'input', span: 24 },
        ],
        info2: [
          { l: '负责人', v: '苑珙', type: 'input', span: 6 },
          { l: '处理日期', v: '2024-08-01', type: 'input', span: 6 },
          { l: '处理说明', v: '正在紧急修复BUG。', type: 'input', span: 24 }
        ],
      }
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.tableData = tableData92[0];
      setTimeout(() => {
        document.querySelector('.border-r').style.height = `${document.querySelector('.cust-act-table').offsetHeight}px`;
      }, 1500)
      this.customColumns = customColumns92;
    })
  },
  methods: {
    /**
     * @author Wrl
     * 重置查询条件
     */
    resetForm() {
      this.formData = {};
    },
    /**
     * @author Wrl
     * 切换查询条件
     */
    changeSearch() {
      this.showSearch = !this.showSearch
    },
    /**
     * @author Wrl
     * 点击树形控件
     */
    handleNodeClick(data) {
      this.contentIdx = data.id;
      this.customColumns = customColumns92;
      this.tableData = tableData92[this.contentIdx];
    },
    /**
     * @author Wrl
     * 显示弹窗
     */
    showModal(type) {
      this.modalState = true;
    },
    /**
     * @author Wrl
     * 关闭弹窗
     */
    closeModal(type) {
      this.modalState = false;
    },
		/**
		 * @author Wrl
		 * 获取分页信息
		 */
		changePage(page) {
			this.page.pageNum = page.pageNum; // 当前页
			this.page.pageSize = page.pageSize; // 每页条数
			this.page.total = page.total; // 总数
		},
  }
};
</script>

<style lang="scss" scoped>
  .problem-management-end {
    ::v-deep {
      .search {
        .el-form-item {
          width: 100%;
        }
        .el-form-item__content {
          width: calc(100% - 90px);
        }
      }
      .btn-modal {
        .el-dialog__header {
          padding: 20px 20px 0;
        }
        .el-dialog__body {
          padding: 0 20px;
        }
      }
      .cust-modal .cust-modal-bgi {
        margin-top: 10px;
      }
    }
    .tree-search {
      width: 200px;
      ::v-deep .el-input__inner {
        border-radius: 20px;
      }
    }
    .cust-tree {
      margin-top: 16px;
    }
    .border-r {
      min-width: 220px;
      border-right: 1px solid #cccccc;
    }
  }
</style>